<script lang="ts">
  import { Router, Route, navigate } from 'svelte-routing'
  import Home from './pages/home.svelte'
  import Login from './pages/login.svelte'
  import "./app.css";
  import { getStorage } from './utils/common';
  import { onMount } from 'svelte';

  const token = getStorage('token');
  console.log(token, 'token');

  // onMount(() => {
  //   // 如果没有 token 且当前不在登录页，则重定向到登录页
  //   if (!token && window.location.pathname !== '/dp/login') {
  //     navigate('/dp/login');
  //   }
  //   // 如果有 token 且在登录页，则重定向到首页
  //   else if (token && window.location.pathname === '/dp/login') {
  //     navigate('/dp');
  //   }
  // });
</script>

<main>
  <Router>
    <!-- <Route path="/dp/login" component={Login} /> -->
    <!-- {#if token} -->
      <Route path="/dp" component={Home} />
    <!-- {/if} -->
  </Router>
</main>

<style>
  :root {
    font-size: 14px;
  }
  @media (max-width: 1280px) {
    :root {
      font-size: 10px;
    }
  }
  @media (max-width: 1024px) {
    :root {
      font-size: 8px;
    }
  }
  /* 1K resolution (up to 1280px) */
</style>
